package com.lifang.framework.util;

import com.lifang.framework.beans.BeansException;

public class ClassUtils {
    public static ClassLoader getDefaultClassLoader() {
        return ClassLoader.getSystemClassLoader();
    }

    public static boolean isCglibProxyClass(Class<?> clazz) {
        return (clazz != null && isCglibProxyClassName(clazz.toString()));
    }

    public static boolean isCglibProxyClassName(String className) {
        return (className != null && className.contains("$$"));
    }

    public static Class<?> forName(String className) throws ClassNotFoundException {
        return Class.forName(className);
    }

    public static Object newInstance(Class<?> aClass) {
        try {
            return aClass.newInstance();
        } catch (Exception ex) {
            throw new BeansException(aClass.getSimpleName() + " No parameterless constructor");
        }
    }

}
